{% extends 'base.html' %}
{% load static %}

  {% block title %}
  <title>审计</title>
  {% endblock title %}
		  
		  {% block leftnav %}
          <li class="nav-item">
            <a href="{% url 'assets:index' %}" class="nav-link">
              <i class="nav-icon fas fa-tachometer-alt"></i>
              <p>
                仪表盘
              </p>
            </a>
          </li>
		  
		  <li class="nav-item">
            <a href="{% url 'assets:hardware' %}" class="nav-link">
              <i class="nav-icon fas fa-copy"></i>
              <p>
                硬件资产
              </p>
            </a>
          </li>
		  <li class="nav-item">
            <a href="{% url 'assets:software' %}" class="nav-link">
              <i class="nav-icon far fa-credit-card"></i>
              <p>
                软件资产
              </p>
            </a>
          </li>
		  <li class="nav-item has-treeview menu-open">
            <a href="#" class="nav-link active">
              <i class="nav-icon fas fa-history"></i>
              <p>
                日志审计
                <i class="right fas fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="{% url 'login:audit_login' %}" class="nav-link active">
                  <i class="fas fa-user-edit nav-icon"></i>
                  <p>用户日志</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="{% url 'assets:operation' %}" class="nav-link">
                  <i class="fas fa-wrench nav-icon"></i>
                  <p>操作日志</p>
                </a>
              </li>
            </ul>
          </li>
		  {% endblock leftnav %}
    
	{% block navheader %}
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>登陆日志</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="{% url 'assets:index' %}">首页</a></li>
              <li class="breadcrumb-item active">登陆日志</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
	{% endblock navheader %}
	
		  {% block content %}
          <div class="card">
            <div class="card-header">
              <h3 class="card-title">登陆日志</h3>
				<div class="card-tools">
				  <button type="button" class="btn btn-tool" data-widget="collapse">
					<i class="fas fa-minus"></i>
				  </button>
				  <button type="button" class="btn btn-tool" data-widget="remove">
					<i class="fas fa-times"></i>
				  </button>
				</div>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              <table id="assets-lists" class="table table-bordered table-striped">
                <thead>
                <tr>
				  <th>用户名,昵称</th>
				  <th>事件类型</th>
				  <th>事件详情</th>
				  <th>IP地址</th>
				  <th>User_Agent</th>
				  <th>事件时间</th>
                </tr>
                </thead>
                <tbody>
				{% for event in events %}
                <tr 
				{% if event.event_type == 3 or event.event_type == 4 %}
				style="color:red;"
				{% elif event.event_type == 1 or event.event_type == 5 %}
				style="color:green;"
				{% endif %}
				>
				  <td>{{ event.user }}</td>
				  <td>{{ event.get_event_type_display }}</td>
				  <td>{{ event.detail }}</td>
				  <td>{{ event.address }}</td>
				  <td>{{ event.useragent }}</td>
				  <td>{{ event.create_time|date:"Y/m/d H:m:s" }}</td>
                </tr>
				{% empty %}
                <tr>没有数据！</tr>
				{% endfor %}
                </tbody>
                <tfoot>
                <tr>
				  <th>用户名,昵称</th>
				  <th>事件类型</th>
				  <th>事件详情</th>
				  <th>IP地址</th>
				  <th>User_Agent</th>
				  <th>事件时间</th>
                </tr>
                </tfoot>
              </table>
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
		  {% endblock content %}
